<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>$Title$</title>
    <script src="../static/js/jquery-1.8.2.min.js"></script>
    <link rel="stylesheet" href="../static/css/css.css">
</head>
<body>
    <table>
        <tr>
            <td>
                <input type="hidden" name="usersId" th:value="${usersId}">
            </td>
        </tr>
        <tr>
            <td>用户名</td>
            <td>
                <input type="text" name="userName" id="userName" disabled="false">
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="password" name="password" id="password" disabled="false">
            </td>
        </tr>
        <tr>
            <td>真实姓名</td>
            <td>
                <input type="text" name="trueName" id="trueName" disabled="false">
            </td>
        </tr>
        <tr>
            <td>电子邮件</td>
            <td>
                <input type="text" name="email" id="email" disabled="false">
            </td>
        </tr>
        <tr>
            <td>联系电话</td>
            <td>
                <input type="text" name="phone" id="phone" disabled="false">
            </td>
        </tr>
        <tr>
            <td>备注</td>
            <td>
                <input type="text" name="comments" id="comments" disabled="false">
            </td>
        </tr>
        <tr>
            <td>性别</td>
            <td>
                <input type="radio" name="sex" value="男" disabled="false">男
                <input type="radio" name="sex" value="女" disabled="false">女
            </td>
        </tr>
        <tr>
            <td>爱好</td>
            <td>
                <input type="checkbox" name="love" value="篮球" disabled="false">篮球
                <input type="checkbox" name="love" value="足球" disabled="false">足球
                <input type="checkbox" name="love" value="乒乓球" disabled="false">乒乓球
            </td>
        </tr>
    </table>
</body>
<script>
    //回显
    /*$.post(
        "info",
        {"id":$("[name=usersId]").val()},
        function (obj) {
            $("#userName").val(obj.userName)
        },"json"
    )*/
        $.ajax({
            url:"/info",
            type:"get",
            data:{"id":$("[name=usersId]").val()},
            dataType:"json",
            success:function (obj) {
                console.log(obj);
                $("#userName").val(obj.userName);
                $("#password").val(obj.password);
                $("#trueName").val(obj.trueName);
                $("#email").val(obj.email);
                $("#phone").val(obj.phone);
                $("#comments").val(obj.comments);
                $("[value="+obj.sex+"]").attr("checked",true);
                var l = obj.love.split(",");
                console.log(l);
                for (var i = 0; i < l.length  ; i++) {
                    $("[value="+l[i]+"]").attr("checked",true);
                }


            }
        })
</script>
</html>